package com.rchat.pocmini.activity.location;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;

import com.airtalkee.sdk.entity.AirContact;
import com.rchat.pocmini.R;

import java.util.List;

/**
 * Created by ljd on 2017/9/29.
 */

public class MemberListAdapter extends BaseAdapter{

    private List<AirContact> data;
    private LayoutInflater inflater;

    public MemberListAdapter(Context context,List<AirContact> data){
        inflater = LayoutInflater.from(context);
        this.data = data;
    }


    @Override
    public int getCount() {
        return data.size();
    }

    @Override
    public Object getItem(int position) {
        return data.get(position);
    }

    @Override
    public long getItemId(int position) {
        return position;
    }

    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
        final ViewHolder holder;
        if (null == convertView) {
            convertView = inflater.inflate(R.layout.item_location_member, null);
            holder = new ViewHolder();
            holder.tvName = (TextView) convertView.findViewById(R.id.textView1);
            convertView.setTag(holder);
        } else {
            holder = (ViewHolder) convertView.getTag();
        }
        holder.tvName.setText(data.get(position).getDisplayName());
        return convertView;
    }

    static class ViewHolder{
        TextView tvName;
    }
}
